using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;

namespace ZLib
{
    public class Zlib
    {
        public static byte[] Compress(byte[] data)
        {
            MemoryStream ms = new MemoryStream();
            Stream s = new DeflaterOutputStream(ms);
            s.Write(data, 0, data.Length);
            s.Close();
            return (byte[])ms.ToArray();
        }

        public static byte[] Decompress(byte[] data, bool large)
        {
            Stream s = new InflaterInputStream(new MemoryStream(data));
            byte[] b = new byte[large ? (1024 * 400) : 8196];
            int count = s.Read(b, 0, b.Length);
            byte[] r = new byte[count];
            Array.Copy(b, 0, r, 0, r.Length);
            return r;
        }
    }
}
